
<%@ page import="BL.AccessDB"%>

<%
HttpSession sess = request.getSession();
String[] subKat = null;
String selKat = request.getParameter("kategorie");
%>

	<h1>Suchen:</h1>
	<form method=post action="centralServlet">
			<input type="hidden" name="act" value="suchen"></input>
		<table>
			<tr>
				<th>PLZ</th>
				<%
					if (request.getParameter("plz") == null) {
				%>
				<td><input type="text" name="plz"></input></td>
								<%
					} else {
				%>
				<td><input type="text" name="plz"
					value="<%=request.getParameter("plz")%>"></input></td>
				<%
					}
				%>
			</tr>
			<tr>
				<th>Ort</th>
								<%
					if (request.getParameter("ort") == null) {
				%>
				<td><input type="text" name="ort"></input></td>
								<%
					} else {
				%>
				<td><input type="text" name="ort"
					value="<%=request.getParameter("ort")%>"></input></td>
				<%
					}
				%>

				
			</tr>
			<tr>
				<th>Strasse/ Nr.</th>
												<%
					if (request.getParameter("strasse") == null) {
				%>
				<td><input type="text" name="strasse"></input>
								<%
					} else {
				%>
				<td><input type="text" name="strasse"
					value="<%=request.getParameter("strasse")%>"></input>
				<%
					}
				%>
												<%
					if (request.getParameter("hausnr") == null) {
				%>
				<input type="text" name="hausnr"></input></td>
								<%
					} else {
				%>
				<input type="text" name="hausnr"
					value="<%=request.getParameter("hausnr")%>"></input></td>
				<%
					}
				%>
			</tr>
			<tr>
			</tr>
			<tr>
				<th>Kategorie</th>
				<td><select name="kategorie" onchange="this.form.submit()">
				<option>Bitte waehlen</option>
						<% 
						String[] kat = AccessDB.getKat();

						for (int i = 0; i < kat.length; i++) {
							if (selKat != null && selKat.equals(kat[i])) {
								out.println("<option selected>" + kat[i] + "</option>");
							} else {
								out.println("<option>" + kat[i] + "</option>");
							}
						}%>

				</select></td>
			</tr>
			<tr>
				<th>Sub-Kategorie</th>
				<td><select id="subKategorie" name="subKategorie">
						<%
							if (selKat == null || selKat.equals("Bitte waehlen")) {
						%>
						<option>(leer)</option>
						<%
							} else {
								subKat = AccessDB.getSubKat(selKat);
						%>
						<option>Bitte waehlen</option>
						<%
							for (int i = 0; i < subKat.length; i++) {
										out.println("<option>" + subKat[i] + "</option>");
								}
							}
						%>
				</select></td>
			</tr>
		</table>
		<br> <input type="submit" name="suchenAct" value="ergebnisseite" >

	</form>


	<%
		if (sess.getAttribute("fehler") != null) {
			if (sess.getAttribute("fehler") != "")
				out.print("<script>alert('" + sess.getAttribute("fehler")
						+ "');</script>");
		}
	%>